<?php

namespace App\Admin\Renderable;



use App\Models\Speaker;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class SpeakerTable extends LazyRenderable
{
    /**选项卡和栏目一的数据
     * @inheritDoc
     */
    public function grid(): Grid
    {
        return Grid::make(new Speaker(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->name->label()->filter()->sortable();
            $grid->photo()->image();
            $grid->email->label()->filter();
            $grid->column('country', '国家');
            $grid->column('time_zone', '时区时差');
            $grid->column('institution', '就职机构及任职')->limit(30);

            $grid->column('areas_of_expertise', '擅长领域');

            $grid->column('medical_category', '医疗领域')->limit(30);
            $grid->column('presenting_meeting', '会议演讲及题目')->limit(30);
            $grid->column('research_sponsor', '演讲研究赞助商')->limit(30);
            $grid->column('association', '学协会及任职')->limit(30);
            $grid->column('journal_position', '期刊及任职及影响因子')->limit(30);
            $grid->column('information_website', '信息来源网页')->limit(30);
            $grid->column('status', '状态')->switch();

            // $grid->column('note', '备注');
            $grid->column('create_time')->display(function ($time) {
                if (empty($time)) {
                    return '暂无';
                }
                return $time->toDateTimeString();
            });
            // $grid->fixColumns(0, -1);
            $grid->model()->orderBy('id', 'desc');
        });
    }
}
